package jmcnet.libcommun.communs
{
	import flexunit.framework.Assert;
	
	import jmcnet.libcommun.communs.structures.FifoStack;
	import jmcnet.libcommun.communs.structures.FiloStack;
	
	import org.flexunit.asserts.assertEquals;

	public class StackTest
	{		
		[Before]
		public function setUp():void
		{
		}
		
		[After]
		public function tearDown():void
		{
		}
		
		[BeforeClass]
		public static function setUpBeforeClass():void
		{
		}
		
		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}
		
		[Test]
		public function testFifoStack():void {
			var fifo:FifoStack = new FifoStack();
			Assert.assertEquals(0, fifo.length);
			
			Assert.assertNull(fifo.pop());
			
			// Add 3 elts
			fifo.push(12);
			fifo.push(13);
			fifo.push(14);
			Assert.assertEquals(3, fifo.length);
			
			assertEquals(12, fifo.pop());
			assertEquals(13, fifo.pop());
			assertEquals(14, fifo.pop());
			Assert.assertNull(fifo.pop());
		}
		
		[Test]
		public function testFiloStack():void {
			var filo:FiloStack = new FiloStack();
			Assert.assertEquals(0, filo.length);
			
			Assert.assertNull(filo.pop());
			
			// Add 3 elts
			filo.push(12);
			filo.push(13);
			filo.push(14);
			Assert.assertEquals(3, filo.length);
			
			assertEquals(14, filo.pop());
			assertEquals(13, filo.pop());
			assertEquals(12, filo.pop());
			Assert.assertNull(filo.pop());
		}
	}
}